package com.leapp.sk.ui.adapter

import android.content.Context
import com.example.mvp.adapter.BaseLibMultipleViewAdapter
import com.example.mvp.binder.BaseDataBinder
import com.example.mvp.delegate.BaseAdapterDelegate
import com.leapp.sk.bean.BeBedTimeStoryEntity
import com.leapp.sk.binder.BaseBinder
import com.leapp.sk.viewdelegate.adapter.find.BeBedTimeStoryLAdapterDelegate
import com.leapp.sk.viewdelegate.adapter.find.BeBedTimeStoryMAdapterDelegate

/**
 * 睡前故事
 * @author  chaohaipeng  on 2018/8/15.
 */
class BeBedTimeStoryAdapter (context: Context, mlist: List<BeBedTimeStoryEntity>,isSingles:Boolean) : BaseLibMultipleViewAdapter<BeBedTimeStoryEntity>(context, mlist){
    /**
     * 数据
     */
    val mList = mlist
    /**
     * 上下文
     */
    val mContext = context
    val isSingle=isSingles
    override fun bindEvenListener(viewDelegate: BaseAdapterDelegate?, position: Int) {
    }

    override fun notifyView(viewDelegate: BaseAdapterDelegate?, position: Int) {
        if (viewDelegate is BeBedTimeStoryMAdapterDelegate){
            viewDelegate.setData()
        }
    }

    override fun getDelegate(position: Int): BaseAdapterDelegate {
        if (isSingle){
            return BeBedTimeStoryLAdapterDelegate::class.java?.newInstance()
        }else{
            return BeBedTimeStoryMAdapterDelegate::class.java?.newInstance()
        }


    }

    override fun getDataBinder(position: Int): BaseDataBinder<*, *> {
        return BaseBinder()
    }

    override fun getItemData(position: Int): Any {
        return mList.get(position)

    }
}